#include "../NewSyndrome-module.h"
#include "admin-public.h"

conf *bot_info;

void
module_init (void)
{
  bot_set_auteur_module ("Thaeron");
  bot_set_desc_module ("Pour mettre et retirer le bot des salons");
  bot_set_ident_module ("join_part");
  bot_set_version_module ("0.1");
  bot_add_cmd_handler ("join", "join_it");
  bot_add_cmd_handler ("part", "part_it");
  bot_info = bot_conf_get_addr ();
}

void
init_dep (char *nom, void *addr)
{
  static byte mut = 0;
  if (!mut++)
    admin_is_admin = NULL;

  if (!strcmp (nom, "admin_is_admin"))
    admin_is_admin = (void *) addr;

#ifdef WIN32
  init_share_dep (nom, addr);
#endif
}


int
join_it (msg * i)
{
  char buffer[101];
  if ((!is_botnick (i->dest)) || (i->nbarg < 2)
      || (admin_is_admin (i->sender) < 800))
    return 0;

  snprintf (buffer, 100, "JOIN %s\n", i->argu[1]);
  buffer[100] = 0;
  bot_send_raw (buffer);

  return 0;
}

int
part_it (msg * i)
{
  char buffer[101];
  if ((!is_botnick (i->dest)) || (i->nbarg < 2)
      || (admin_is_admin (i->sender) < 800))
    return 0;

  snprintf (buffer, 100, "PART %s\n", i->argu[1]);
  buffer[100] = 0;
  bot_send_raw (buffer);

  return 0;
}
